package cn.aitrox.ry.service.oss.api;

import cn.aitrox.ry.bean.RespResult;
import cn.aitrox.ry.service.oss.dto.FileRestoreInfoDto;
import cn.aitrox.ry.service.oss.dto.in.DowanloadUrlGetInDto;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public interface OssFileApi {

    @PostMapping(value = "/oss/file/url/get")
    RespResult<List<FileRestoreInfoDto>> urlGet(@RequestBody DowanloadUrlGetInDto input);

    @PostMapping(value = "/oss/file/put")
    RespResult put(@RequestParam("key") String key, @RequestPart("file") MultipartFile mfile, @RequestParam("ossType") String ossType);

    @PostMapping(value = "/oss/file/put/local")
    RespResult putLocal(@RequestParam("key") String key, @RequestParam("filePath") String filePath, @RequestParam("ossType") String ossType);

    @DeleteMapping(value = "/oss/file/delete")
    RespResult delete(@RequestParam("key") String key, @RequestParam("ossType") String ossType);

    @PostMapping(value = "/oss/file/copy")
    RespResult copy(@RequestParam("sourceKey") String sourceKey, @RequestParam("targetKey") String targetKey, @RequestParam("ossType") String ossType);

    @PostMapping(value = "/oss/file/move")
    RespResult move(@RequestParam("filePath") String filePath, @RequestParam("key") String key, @RequestParam("ossType") String ossType);

    @RequestMapping("/oss/file/download/**")
    void download(HttpServletResponse response) throws IOException;
}
